package com.hulk.summary.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum SummaryType {


    MD2("DigestAlgorithm","MD2"),
    MD5("DigestAlgorithm","MD5"),
    SHA1("DigestAlgorithm","SHA-1"),
    SHA256("DigestAlgorithm","SHA-256"),
    SHA384("DigestAlgorithm","SHA-384"),
    SHA512("DigestAlgorithm","SHA-512"),
    HmacMD5("HmacAlgorithm","HmacMD5"),
    HmacSHA1("HmacAlgorithm","HmacSHA1"),
    HmacSHA256("HmacAlgorithm","HmacSHA256"),
    HmacSHA384("HmacAlgorithm","HmacSHA384"),
    HmacSHA512("HmacAlgorithm","HmacSHA512"),
    SM3("SM","SM3");

    private String type;
    private String value;


    public static SummaryType getEnum(String name) {
        SummaryType resultEnum = null;
        SummaryType[] ProfileAry = SummaryType.values();
        for (int i = 0; i < ProfileAry.length; i++) {
            if (Objects.equals(ProfileAry[i].name(),name)) {
                resultEnum = ProfileAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static String getType(String name) {
        for (SummaryType obj : SummaryType.values()) {
            if (Objects.equals(name, obj.name())) {
                return obj.type;
            }
        }
        return null;
    }

    public static String getValue(String name) {
        for (SummaryType obj : SummaryType.values()) {
            if (Objects.equals(name, obj.name())) {
                return obj.value;
            }
        }
        return null;
    }

    public static String getTypeByVal(String value) {
        for (SummaryType obj : SummaryType.values()) {
            if (Objects.equals(value, obj.value)) {
                return obj.type;
            }
        }
        return null;
    }
}
